Sync eng/common directory with azure-sdk-tools for PR 15278#4272
Sync eng/common directory with azure-sdk-tools for PR 15278#4272
Conversation
Adds an opt-in capability to the shared TypeSpec emitter pipeline template that bundles an emitter package and uploads it to the typespec playground blob storage. The uploaded <pkgName>/latest.json import map is consumed by in-browser playgrounds (e.g. https://azure.github.io/typespec-azure) via their additionalPlaygroundPackages mechanism. Self-contained tooling lives in eng/common/playground-bundle/ and mirrors @typespec/bundle-uploader from microsoft/typespec (which is private and cannot be installed from npm). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR syncs eng/common changes from azure-sdk-tools PR 15278 by introducing a self-contained TypeSpec emitter bundling + upload utility and wiring it into the shared archetype-typespec-emitter.yml pipeline template.
Changes:
- Added
eng/common/playground-bundle/Node-based tool to bundle a TypeSpec emitter and upload it to the TypeSpec playground blob storage. - Added documentation for the new bundler/uploader utility.
- Updated
archetype-typespec-emitter.ymlto optionally run the bundle+upload flow (internal, non-PR builds only).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| eng/common/playground-bundle/upload.mjs | New Node script that bundles an emitter and uploads JS + manifest + updates latest.json in blob storage. |
| eng/common/playground-bundle/package.json | Defines pinned dependencies and Node engine requirement for the uploader tool. |
| eng/common/playground-bundle/package-lock.json | Locks transitive dependencies for reproducible installs in pipelines. |
| eng/common/playground-bundle/README.md | Documents purpose and pipeline invocation details for the uploader tool. |
| eng/common/pipelines/templates/archetype-typespec-emitter.yml | Adds UploadPlaygroundBundle parameter and pipeline steps to install/run the uploader. |
Files not reviewed (1)
- eng/common/playground-bundle/package-lock.json: Language not supported
| const content = JSON.stringify(manifest); | ||
| await blob.upload(content, content.length, { | ||
| blobHTTPHeaders: { blobContentType: "application/json; charset=utf-8" }, | ||
| conditions: { ifNoneMatch: "*" }, | ||
| }); |
There was a problem hiding this comment.
BlockBlobClient.upload expects contentLength in bytes, but content.length is UTF-16 code unit count and can be wrong for non-ASCII JSON. Use Buffer.byteLength(content, "utf8") (or switch to uploadData(Buffer.from(content))) to ensure the Content-Length matches the actual payload.
| async function updatePackageLatest(container, pkgName, index) { | ||
| const blob = container.getBlockBlobClient(normalizePath(joinUnix(pkgName, "latest.json"))); | ||
| const content = JSON.stringify(index); | ||
| await blob.upload(content, content.length, { |
There was a problem hiding this comment.
Same issue as above: content.length is not a reliable byte length for UTF-8 JSON when calling BlockBlobClient.upload. Use Buffer.byteLength(...) or uploadData(Buffer.from(content)) for latest.json uploads.
| await blob.upload(content, content.length, { | |
| await blob.uploadData(Buffer.from(content, "utf8"), { |
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#15278 See eng/common workflow